Skip to content

fix: resolve failing tests and type errors across api and shared packages#52

Open
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2430-1781408112
Open

fix: resolve failing tests and type errors across api and shared packages#52
stooit wants to merge 1 commit into
mainfrom
quantcode/e2e-tier2-2430-1781408112

Conversation

@stooit

@stooit stooit commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all failing tests and TypeScript errors across the api and shared packages. After this change bun test reports 22 pass / 0 fail and bunx tsc --noEmit is clean.

Fixes

  • Pagination utility (packages/shared/src/utils/pagination.ts): implemented the previously-stubbed paginate() — page slicing via (page-1)*size, totalPages = Math.ceil(total/size), returns { data, page, pageSize, total, totalPages } per the test contract.
  • Auth middleware (packages/api/src/middleware/auth.ts): fixed the HTTP-method case-sensitivity bug so public routes (e.g. POST /users) are correctly matched and don't require a token. Wired up types so the process global resolves.
  • Shared User type: aligned the field name on username (was userName) across the shared type and all api source usages, matching what the tests and route handlers expect.
  • Route handlers (packages/api/src/routes/users.ts): added the missing badRequest import that was causing the 400-on-missing-fields path to fail.
  • TS config: wired up bun-types so bun:test and process resolve under tsc --noEmit.

Verification

  • bun test → 22 pass, 0 fail
  • bunx tsc --noEmit → clean

Constraints honoured

  • No test files modified.
  • No new dependencies added.
  • Changes kept minimal and scoped to what the tests/types required.

Assumptions

  • Since test files are immutable and use username, the canonical field name was standardised to username (the shared type previously used userName).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant